<?php

declare(strict_types=1);

namespace App\Request;

use Hyperf\Validation\Request\FormRequest;

class SysRoleRequest extends FormRequest
{
    protected array $scenes = [
        'add' => ['role_name', 'rules', 'status'],
        'edit' => ['role_id', 'role_name','rules', 'status'],
    ];
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'role_id' => 'required|integer',
            'role_name' => 'required|min:2|max:50',
            'rules' => 'required|array',
            'status' => 'required|integer',
        ];
    }

    /**
     * 获取已定义验证规则的错误消息
     */
    public function messages(): array
    {
        return [
            'role_id.required' => '参数错误-0',
            'role_id.integer' => '参数错误-1',
            'role_name.required' => '账号不能为空',
            'role_name.min' => '账号格式不正确',
            'role_name.max' => '账号格式不正确',
            'rules.required' => '权限不能为空',
            'rules.array' => '权限格式错误',
            'status.required' => '格式错误-2',
            'status.integer' => '格式错误-3',
        ];
    }
}
